<template>
	<view>
		<detail-info :item="data"></detail-info>
		<view class="grace-bold grace-h4" style="padding: 20rpx;">最新评论 {{comment.count}}</view>
		<view class="uni-comment">
			<block v-for="(item,index) in comment.list" :key="index">
				<comment-list :item="item"></comment-list>
			</block>
		</view>
		<view style="height: 120rpx;"></view>
		<!-- 输入框 -->
		<chat-input @submit="submit"></chat-input>
		<!-- 分享 -->
		<share-dialog :show="show" @closeDialog="closeDialog"></share-dialog>
	</view>
</template>

<script>
import NewsList from '../../components/detail-info/detail-info';
import ChatInput from '../../components/chat-input/chat-input';
import CommentList from '../../components/comment-list/comment-list';
import ShareDialog from '../../components/share-dialog/share-dialog';
var graceJS = require('@/Grace.JS/grace.js');
export default {
	data() {
		return {
			show:false,
			comment:{
				count:20,
				list:[
					{
						id:1,
						fid:0,
						userpic:"../../static/demo/userpic/11.jpg",
						username:"飞屋睿",
						time:"1555400035",
						data:"35岁程序员，年后第一天被辞退",
					},
					{
						id:2,
						fid:1,
						userpic:"../../static/demo/userpic/12.jpg",
						username:"飞屋睿",
						time:"1555400035",
						data:"35岁程序员，年后第一天被辞退",
					},
					{
						id:3,
						fid:1,
						userpic:"../../static/demo/userpic/10.jpg",
						username:"低头看鱼",
						time:"1555400035",
						data:"呵呵",
					},
					{
						id:4,
						fid:0,
						userpic:"../../static/demo/userpic/2.jpg",
						username:"涛哥哥",
						time:"1555400035",
						data:"垃圾",
					}
				]
			},
			data: {
				userAvatar: '../../static/demo/userpic/10.jpg',
				username: '涛哥哥',
				sex: 1, //0 男 1女
				age: 33,
				isFollow: false,
				title: '我是标题啦啦啦啦',
				video: false, //video
				share: false,
				address: '深圳 龙岗',
				titlepic: '../../static/demo/datapic/12.jpg',
				morepic: ['../../static/demo/datapic/12.jpg'],
				likeNum: 11,
				commentNum: 10,
				shareNum: 10
			}
		};
	},
	onNavigationBarButtonTap(e) {
		if (e.index == 0) {
			this.showDialog();
		}
	},
	onLoad(e) {
		// 设置标题
		graceJS.setNavBar({ title: JSON.parse(e.detailData).title });
	},
	methods: {
		submit(data) {
			let now = graceJS.now();
			let obj = {
					id:100,
					fid:0,
					userpic:"../../static/demo/userpic/11.jpg",
					username:"飞屋睿",
					time: now,
					data: data
			};
			this.comment.list.push(obj);
		},
		showDialog(){
			this.show = true;
		},
		closeDialog(){
			this.show = false;
		},
	},
	comments: {
		NewsList,
		CommentList,
		ChatInput,
		ShareDialog
	}
};
</script>

<style lang="stylus">
.uni-comment
	padding 0 20rpx
	display flex
	flex-grow 1
	flex-direction column
</style>
